<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="login.css">
    <script src="jQuery/jquery-3.6.0.min.js"></script>
</head>

<body>
    <div class="top">
        <div style="width: 980px;">
            <a class="biaoti" href="homepage.php">宇宙音乐</a>
            <a class="suoyin">评论</a>
            <a class="suoyin">合作</a>
            <a class="suoyin">客服</a>
            <a class="suoyin">我的购买</a>
        </div>
    </div>

    <div class="middle">
        <div class="denglu">
            <p class="biao1">登录</p>
            <p class="neirong">请输入用户名:</p>
            <input id="name">
            <p class="neirong">请输入密码:</p>
            <input id="password">
            <p class="neirong" style="font-size: 15px;"><input type="checkbox">在这台电脑上记住我</p>
            <p><button id="btn">登录</button></p>
           <p>  <button onclick="window.location.href='register.php';">注册</button>  </p>
            <p style="text-align: center;"><a>忘记密码?</a></p>
        </div>
    </div>
    <div class="bottom">
        <p>
            <a>MUSIC</a>树立版权意识，支持正版音乐！
        </p>
        <hr><br>
        <p>关于 宇宙音乐\推广合作请联系电子邮箱：2333333333@google.com</p>
    </div>
</body>

<script>
    //登录验证
    var btn = document.getElementById("btn").addEventListener("click", function() {
        var name = document.getElementById("name").value;
        var password = document.getElementById("password").value;
        if (name == "" || password == "") {
            alert("错误，用户名或密码不能为空!");
            return 0;
        }
        if (name.length < 6 || password.length < 6) {
            alert("错误，用户名或密码不能少于6位!");
            return 0;
        }
        let a = localStorage.getItem("用户名");
        let b = localStorage.getItem("密码");
        if (name != a || password != b) {
            alert("用户名或密码错误!");
        } else {
            location.href = "homepage.php";
            localStorage.setItem("登录", "1");
        }
    });
    //登录状态判定
    window.onload = function() {
        let denglu = localStorage.getItem("登录");
        if (denglu == "1") {
            window.location.href = "homepage.php";
        }
        localStorage.setItem("用户名", "202124430416");
        localStorage.setItem("密码", "123456");
    }
</script>

</html>